package main

import (
	"fmt"
	"time"
)

func test() {
	//timer只会触发一次
	timer := time.NewTimer(2 * time.Second)
	fmt.Println("now = ", time.Now())

	for {
		t := <-timer.C //导致死锁，只会赋值一次
		fmt.Println("t = ", t)
	}

}

func main() {
	timer := time.NewTimer(2 * time.Second)
	fmt.Println("now = ", time.Now())

	t := <-timer.C
	fmt.Println("t = ", t)

	fmt.Println("-------")
	test()
}
